<template>
	<div>
		<span>
			<el-upload class="upload-demo" ref="upload" drag action="http://localhost:8082/course/upload" multiple :auto-upload="false"
			 :limit="5" :data="uploadData" :on-success="handleFilUploadSuccess"  :on-remove="handleRemove">
				<i class="el-icon-upload"></i>
				<div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
				<div class="el-upload__tip" slot="tip">只能上传 Excel 文件，且不超过500kb</div>
			</el-upload>
		</span>
		<span slot="footer" class="dialog-footer">
			<el-button @click="dialogVisible = false">取 消</el-button>
			<el-button type="primary" @click="handleUpload">确 定</el-button>
		</span>
	</div>
</template>
<script>
	export default {
		props: ['uploadCourse'],
		data() {
			return {
				uploadData:{
					courseName:"",
					username:""
				}
			};
		},
		created() {console.log(this.$store.getters.getuname)
			this.uploadData.courseName= this.uploadCourse;
			this.uploadData.username=this.$store.getters.getuname;
			
		},
		methods: {
			
			handleRemove(file, fileList) {
				console.log(file, fileList);
			},
			submitUpload() {
				this.$refs.upload.submit();
			},
			// 文件上传成功时的函数
			handleFilUploadSuccess(res, file, fileList) {
				console.log(res, file, fileList)
				this.$message.success("上传成功")
				this.$emit("getData()")
			},
			handleUpdate() {},
			// 处理文件上传的函数
			handleUpload() {
				
				this.submitUpload()
			}
		},
	};
</script>
<style>
	.btn-upload {
		top: 70px;
		right: 40px;
		position: fixed;
		z-index: 100;
		border-radius: 30px;
		box-shadow: 0 2px 12px 0 rgba(91, 156, 255, 0.9)
	}

	.el-upload {
		margin: 5px;
	}
</style>
